home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / dosrcss.zip / RCSBASE.H < prev    next >
C/C++ Source or Header  |  1990-07-18  |  15KB  |  436 lines

  1. /*
  2.  *                     RCS common definitions and data structures
  3.  */
  4. #define RCSBASE "$Id: rcsbase.h,v 5.3 90/07/15 20:28:09 lfk Release $"
  5.  
  6. /* Copyright (C) 1982, 1988, 1989 Walter Tichy
  7.    Distributed under license by the Free Software Foundation, Inc.
  8.  
  9. This file is part of RCS.
  10.  
  11. RCS is free software; you can redistribute it and/or modify
  12. it under the terms of the GNU General Public License as published by
  13. the Free Software Foundation; either version 1, or (at your option)
  14. any later version.
  15.  
  16. RCS is distributed in the hope that it will be useful,
  17. but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19. GNU General Public License for more details.
  20.  
  21. You should have received a copy of the GNU General Public License
  22. along with RCS; see the file COPYING.  If not, write to
  23. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  24.  
  25. Report problems and direct all questions to:
  26.  
  27.     rcs-bugs@cs.purdue.edu
  28.  
  29. */
  30.  
  31.  
  32.  
  33. /*****************************************************************************
  34.  * INSTRUCTIONS:
  35.  * =============
  36.  * The following should be handled in the Makefile:
  37.  *     For USG Unix, define USG; for BSD Unix, don't (see ifdef USG).
  38.  *     For 4.2 bsd, define V4_2BSD; this will replace the routines
  39.  *     getwd() and rename() with the corresponding ones in the C-library.
  40.  *     V4_2BSD also selects different definitions for the macros NCPFN and NCPPN
  41.  *     (max. number of characters per filename, number of characters per path name).
  42.  *     Define STRICT_LOCKING appropriately (see STRICT_LOCKING).
  43.  * The following need be changed for porting to a different machine:
  44.  *     Define SMALLOG for a machine with small memory (like the PDP11).
  45.  *     SMALLOG conserves space for log messages.
  46.  *     Change BYTESIZ if necessary.
  47.  * If you need to change the comment leaders, update the table comtable[]
  48.  * in rcsfnms.c. (This can wait until you know what a comment leader is.)
  49.  *****************************************************************************
  50.  */
  51.  
  52.  
  53. /* $Log:    rcsbase.h,v $
  54.  * Revision 5.3  90/07/15  20:28:09  lfk
  55.  *  Most major fixes added between rev 5.1 and rev 5.5:
  56.  *       signals fixed so they work on MS-DOS
  57.  *       Added MKS arguments code so argv can be large
  58.  *       added code to handle slashes a'la Unix
  59.  *       added more file extensions to system from MS-DOS
  60.  * 
  61.  * Revision 5.2  90/07/15  11:32:24  ROOT_DOS
  62.  * DOS version of RCS 4.0 checked in for MODS
  63.  * by lfk@athena.mit.edu
  64.  * Also update to MSC 6.0
  65.  * 
  66.  * revision 5.1 koya 90/01/24 06:28:49
  67.  * Initial revision
  68.  * 
  69.  * Revision 4.9  89/05/01  15:17:14  narten
  70.  * botched previous USG fix 
  71.  * 
  72.  * Revision 4.8  89/05/01  14:53:05  narten
  73.  * changed #include <strings.h> -> string.h for USG systems.
  74.  * 
  75.  * Revision 4.7  88/11/08  15:58:45  narten
  76.  * removed defs for functions loaded from libraries
  77.  * 
  78.  * Revision 4.6  88/11/08  12:04:06  narten
  79.  * changes from eggert@sm.unisys.com (Paul Eggert)
  80.  * 
  81.  * Revision 4.6  88/08/09  19:12:36  eggert
  82.  * Shrink stdio code size; remove lint; permit -Dhshsize=nn.
  83.  * 
  84.  * Revision 4.5  87/12/18  17:06:41  narten
  85.  * made removed BSD ifdef, now uses V4_2BSD
  86.  * 
  87.  * Revision 4.4  87/10/18  10:29:49  narten
  88.  * Updating version numbers
  89.  * Changes relative to 1.1 are actually relative to 4.2
  90.  * 
  91.  * Revision 1.3  87/09/24  14:02:25  narten
  92.  * changes for lint
  93.  * 
  94.  * Revision 1.2  87/03/27  14:22:02  jenkins
  95.  * Port to suns
  96.  * 
  97.  * Revision 1.1  84/01/23  14:50:14  kcs
  98.  * Initial revision
  99.  * 
  100.  * Revision 4.2  83/12/20  16:04:20  wft
  101.  * merged 3.6.1.1 and 4.1 (SMALLOG, logsize).
  102.  * moved setting of STRICT_LOCKING to Makefile.
  103.  * changed DOLLAR to UNKN (conflict with KDELIM).
  104.  * 
  105.  * Revision 4.1  83/05/04  09:12:41  wft
  106.  * Added markers Id and RCSfile.
  107.  * Added Dbranch for default branches.
  108.  * 
  109.  * Revision 3.6.1.1  83/12/02  21:56:22  wft
  110.  * Increased logsize, added macro SMALLOG.
  111.  * 
  112.  * Revision 3.6  83/01/15  16:43:28  wft
  113.  * 4.2 prerelease
  114.  * 
  115.  * Revision 3.6  83/01/15  16:43:28  wft
  116.  * Replaced dbm.h with BYTESIZ, fixed definition of rindex().
  117.  * Added variants of NCPFN and NCPPN for bsd 4.2, selected by defining V4_2BSD.
  118.  * Added macro DELNUMFORM to have uniform format for printing delta text nodes.
  119.  * Added macro DELETE to mark deleted deltas.
  120.  *
  121.  * Revision 3.5  82/12/10  12:16:56  wft
  122.  * Added two forms of DATEFORM, one using %02d, the other %.2d.
  123.  *
  124.  * Revision 3.4  82/12/04  20:01:25  wft
  125.  * added LOCKER, Locker, and USG (redefinition of rindex).
  126.  *
  127.  * Revision 3.3  82/12/03  12:22:04  wft
  128.  * Added dbm.h, stdio.h, RCSBASE, RCSSEP, RCSSUF, WORKMODE, TMPFILE3,
  129.  * PRINTDATE, PRINTTIME, map, and ctab; removed Suffix. Redefined keyvallength
  130.  * using NCPPN. Changed putc() to abort on write error.
  131.  *
  132.  * Revision 3.2  82/10/18  15:03:52  wft
  133.  * added macro STRICT_LOCKING, removed RCSUMASK.
  134.  * renamed JOINFILE[1,2] to JOINFIL[1,2].
  135.  *
  136.  * Revision 3.1  82/10/11  19:41:17  wft
  137.  * removed NBPW, NBPC, NCPW.
  138.  * added typdef int void to aid compiling
  139.  */
  140.  
  141.  
  142.  
  143. #include <stdio.h>
  144. #ifdef MKS
  145. #define STREQ(a,b)    ( strcmp( (a), (b) ) == 0 )
  146. #endif
  147. #ifdef USG
  148. #include <string.h>
  149. #else
  150. #include <strings.h>
  151. #endif
  152. #undef putc         /* will be redefined */
  153.  
  154.  
  155. #ifdef USG
  156. #       define rindex    strrchr
  157. #       define DATEFORM  "%.2d.%.2d.%.2d.%.2d.%.2d.%.2d"
  158. #else
  159. #       define DATEFORM  "%02d.%02d.%02d.%02d.%02d.%02d"
  160. #endif
  161. /* Make sure one of %02d or %.2d prints a number with a field width 2, with
  162.  * leading zeroes. For example, 0, 1, and 22 must be printed as 00, 01, and
  163.  * 22. Otherwise, there will be problems with the dates.
  164.  */
  165.  
  166. #define PRINTDATE(file,date) fprintf(file,"%.2s/%.2s/%.2s",date,date+3,date+6)
  167. #define PRINTTIME(file,date) fprintf(file,"%.2s:%.2s:%.2s",date+9,date+12,date+15)
  168. /* print RCS format date and time in nice format from a string              */
  169.  
  170. /*
  171.  * Parameters
  172.  */
  173. #define BYTESIZ             8 /* number of bits in a byte                   */
  174.  
  175. /*#define STRICT_LOCKING    0 /* 0 sets the default locking to non-strict;  */
  176.                               /* used in experimental environments.         */
  177.                               /* 1 sets the default locking to strict;      */
  178.                               /* used in production environments.           */
  179.                   /* STRICT_LOCKING is set in the Makefile!     */
  180. #ifndef hshsize
  181. #define hshsize           239 /* hashtable size; MUST be prime and -1 mod 4 */
  182.                               /* other choices: 547 or 719                  */
  183. #endif
  184.  
  185. #define strtsize (hshsize * 50) /* string table size                        */
  186. #ifdef SMALLOG
  187. #  define logsize         1024 /* max. size of log message for pdp11        */
  188. #else
  189. #  define logsize         4096 /* max. size of log message for others       */
  190. #endif
  191. #define revlength          30 /* max. length of revision numbers            */
  192. #define datelength         20 /* length of a date in RCS format             */
  193. #define joinlength         20 /* number of joined revisions permitted       */
  194. #ifdef MSDOS        /* Added by $Author: lfk $ */
  195. #    ifdef MKS
  196. #        define RCSDIR         "rcs/" /* subdirectory for RCS files                 */
  197. #    else
  198. #        define RCSDIR         "RCS\\" /* subdirectory for RCS files                 */
  199. #    endif /* MKS */
  200. #else
  201. #define RCSDIR         "RCS/" /* subdirectory for RCS files                 */
  202. #endif /* MSDOS */
  203. #ifdef MSDOS        /* Added by $Author: lfk $ */
  204. #define RCSSUF            '\0' /* suffix for RCS files                       */
  205. #define RCSSEP            '\0' /* separator for RCSSUF                       */
  206. #else
  207. #define RCSSUF            'v' /* suffix for RCS files                       */
  208. #define RCSSEP            ',' /* separator for RCSSUF                       */
  209. #endif /* MSDOS */
  210. #define KDELIM            '$' /* delimiter for keywords                     */
  211. #define VDELIM            ':' /* separates keywords from values             */
  212. #define DEFAULTSTATE    "Exp" /* default state of revisions                 */
  213. #ifdef V4_2BSD
  214. #  define NCPFN           256 /* number of characters per filename          */
  215. #  define NCPPN          1024 /* number of characters per pathname          */
  216. #else
  217. #ifdef MSDOS        /* Added by $Author: lfk $ */
  218. #  define NCPFN            13 /* number of characters per filename          */
  219. #  define NCPPN              66 /* number of characters per pathname          */
  220. #else
  221. #  define NCPFN            14 /* number of characters per filename          */
  222. #  define NCPPN       6*NCPFN /* number of characters per pathname          */
  223. #endif /* MSDOS */
  224. #endif
  225. #define keylength          20 /* buffer length for expansion keywords       */
  226. #define keyvallength NCPPN+revlength+datelength+60
  227.                               /* buffer length for keyword expansion        */
  228.  
  229.  
  230.  
  231. #define true     1
  232. #define false    0
  233. #define nil      0
  234. #define elsif    else if
  235. #define elif     else if
  236.  
  237.  
  238. /* temporary file names */
  239.  
  240. #ifdef MSDOS            /* Added by $Author: lfk $ */
  241. #define NEWRCSFILE  "nwXXXXXX"
  242. #define DIFFILE     "ciXXXXXX"
  243. #define TMPFILE1    "t1XXXXXX"
  244. #define TMPFILE2    "t2XXXXXX"
  245. #define TMPFILE3    "t3XXXXXX"
  246. #define JOINFIL2    "j2XXXXXX"
  247. #define JOINFIL3    "j3XXXXXX"
  248. #else
  249. #define NEWRCSFILE  ",RCSnewXXXXXX"
  250. #define DIFFILE     ",RCSciXXXXXX"
  251. #define TMPFILE1    ",RCSt1XXXXXX"
  252. #define TMPFILE2    ",RCSt2XXXXXX"
  253. #define TMPFILE3    ",RCSt3XXXXXX"
  254. #define JOINFIL2    ",RCSj2XXXXXX"
  255. #define JOINFIL3    ",RCSj3XXXXXX"
  256. #endif /* MSDOS */
  257.  
  258.  
  259. #define putc(x,p) (--(p)->_cnt>=0? ((int)(*(p)->_ptr++=(unsigned)(x))):fflsbuf((unsigned)(x),p))
  260. /* This version of putc prints a char, but aborts on write error            */
  261.  
  262. #define GETC(in,out,echo) (c=getc(in), echo?putc(c,out):c)
  263. /* GETC modifies a local variable c; a kludge, but smaller and faster.      */
  264. /* GETC writes a del-character (octal 177) on end of file                   */
  265.  
  266. #ifdef MSDOS
  267. #define WORKMODE(RCSmode) (RCSmode & ~S_IWRITE)|((lockflag||!StrictLocks)? ( S_IWRITE | S_IREAD ) : 0000 )
  268. #else
  269. #define WORKMODE(RCSmode) (RCSmode&~0222)|((lockflag||!StrictLocks)?0600:0000)
  270. #endif /* MSDOS */
  271. /* computes mode of working file: same as RCSmode, but write permission     */
  272. /* determined by lockflag and StrictLocks.                                  */
  273.  
  274.  
  275. /* character classes and token codes */
  276. enum tokens {
  277. /* char classes*/  DIGIT, IDCHAR, NEWLN, LETTER, PERIOD, SBEGIN, SPACE, UNKN,
  278. /* tokens */       COLON, DATE, EOFILE, ID, KEYW, NUM, SEMI, STRING,
  279. };
  280.  
  281. #define AT      SBEGIN  /* class SBEGIN (string begin) is returned by lex. anal. */
  282. #define SDELIM  '@'     /* the actual character is needed for string handling*/
  283. /* these must be changed consistently, for instance to:
  284.  * #define DQUOTE       SBEGIN
  285.  * #define SDELIM       '"'
  286.  * #define AT           IDCHAR
  287.  * there should be no overlap among SDELIM, KDELIM, and VDELIM
  288.  */
  289.  
  290. /* other characters */
  291.  
  292. #define ACCENT   IDCHAR
  293. #define AMPER    IDCHAR
  294. #define BACKSL   IDCHAR
  295. #define BAR      IDCHAR
  296. #define COMMA    UNKN
  297. #define DIVIDE   IDCHAR
  298. #define DOLLAR   UNKN                /* overlap with KDELIM */
  299. #define DQUOTE   IDCHAR
  300. #define EQUAL    IDCHAR
  301. #define EXCLA    IDCHAR
  302. #define GREAT    IDCHAR
  303. #define HASH     IDCHAR
  304. #define INSERT   UNKN
  305. #define LBRACE   IDCHAR
  306. #define LBRACK   IDCHAR
  307. #define LESS     IDCHAR
  308. #define LPARN    IDCHAR
  309. #define MINUS    IDCHAR
  310. #define PERCNT   IDCHAR
  311. #define PLUS     IDCHAR
  312. #define QUEST    IDCHAR
  313. #define RBRACE   IDCHAR
  314. #define RBRACK   IDCHAR
  315. #define RPARN    IDCHAR
  316. #define SQUOTE   IDCHAR
  317. #define TILDE    IDCHAR
  318. #define TIMES    IDCHAR
  319. #define UNDER    IDCHAR
  320. #define UPARR    IDCHAR
  321.  
  322.  
  323.  
  324.  
  325. /***************************************
  326.  * Data structures for the symbol table
  327.  ***************************************/
  328.  
  329.  
  330. /* Hash table entry */
  331. struct hshentry {
  332.         char              * num;      /* pointer to revision number (ASCIZ) */
  333.         char              * date;     /* pointer to date of checking        */
  334.         char              * author;   /* login of person checking in        */
  335.         char              * lockedby; /* who locks the revision             */
  336.         char              * log;      /* log message requested at checkin   */
  337.         char              * state;    /* state of revision (Exp by default) */
  338.         struct branchhead * branches; /* list of first revisions on branches*/
  339.         struct hshentry   * next;     /* next revision on same branch       */
  340.         int                 insertlns;/* lines inserted (computed by rlog)  */
  341.         int                 deletelns;/* lines deleted  (computed by rlog)  */
  342.         char                selector; /* marks entry for selection/deletion */
  343. };
  344.  
  345. /* list element for branch lists */
  346. struct branchhead {
  347.         struct hshentry   * hsh;
  348.         struct branchhead * nextbranch;
  349. };
  350.  
  351. /* accesslist element */
  352. struct access {
  353.         char              * login;
  354.         struct access     * nextaccess;
  355. };
  356.  
  357. /* list element for locks  */
  358. struct lock {
  359.         char              * login;
  360.         struct hshentry   * delta;
  361.         struct lock       * nextlock;
  362. };
  363.  
  364. /* list element for symbolic names */
  365. struct assoc {
  366.         char              * symbol;
  367.         struct hshentry   * delta;
  368.         struct assoc      * nextassoc;
  369. };
  370.  
  371.  
  372. /* common variables (getadmin and getdelta())*/
  373. extern char            * Comment;
  374. extern struct access   * AccessList;
  375. extern struct assoc    * Symbols;
  376. extern struct lock     * Locks;
  377. extern struct hshentry * Head;
  378. extern struct hshentry * Dbranch;
  379. extern int               StrictLocks;
  380. extern int               TotalDeltas;
  381. #ifndef lint
  382. static char copyright[]="Copyright (C) 1982 by Walter F. Tichy";
  383. #endif
  384.  
  385. /* common variables (lexical analyzer)*/
  386. extern enum tokens map[];
  387. #define ctab (&map[1])
  388. extern enum tokens       nexttok;
  389. extern int               hshenter;
  390. extern char            * NextString;
  391. extern char            * cmdid;
  392.  
  393. #if defined(USG) || defined(V4_2BSD)
  394. #define VOID    (void)
  395. #else
  396. typedef int void;
  397. #define VOID
  398. #endif
  399.  
  400. /* common routines */
  401. extern char *talloc();
  402. extern int serror();
  403. extern int faterror();
  404. extern int fatserror();
  405. extern void ignoreints();
  406. extern void catchints();
  407. extern void restoreints();
  408.  
  409. #ifdef USG
  410. extern int sprintf();
  411. #endif
  412.  
  413. /*
  414.  * Markers for keyword expansion (used in co and ident)
  415.  */
  416. #define AUTHOR          "Author"
  417. #define DATE            "Date"
  418. #define HEADER          "Header"
  419. #define IDH             "Id"
  420. #define LOCKER          "Locker"
  421. #define LOG             "Log"
  422. #define RCSFILE         "RCSfile"
  423. #define REVISION        "Revision"
  424. #define SOURCE          "Source"
  425. #define STATE           "State"
  426.  
  427. enum markers { Nomatch, Author, Date, Header, Id,
  428.            Locker, Log, RCSfile, Revision, Source, State };
  429.  
  430. #define DELNUMFORM      "\n\n%s\n%s\n"
  431. /* used by putdtext and scanlogtext */
  432. #define DELETE          'D'
  433. /* set by rcs -o and used by puttree() in rcssyn */
  434.  
  435.  
  436.